﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twipler.App.Parse.Code;
using Xunit;
using Xunit.Extensions;

namespace UnitTests.App.Parse.Code
{
    public class TokenParseExpect
    {
        [Theory]
        [InlineData("1 m", 0, 0, 1, 0)]
        [InlineData("1m", 0, 0, 1, 0)]
        [InlineData("13m", 0, 0, 13, 0)]
        [InlineData("12345 h", 0, 0, 13, 0)]
        [InlineData("\"12345 h\"", 0, 0, 13, 0)]
        [InlineData("\"444d\"", 444, 0, 0, 0)] 
        [InlineData("\"23 s\"", 0, 0, 0, 23)]
        public void ExpectTimeSpan(string input, int days, int hours, int minutes, int seconds)
        {
            TokenParser parser = new TokenParser(input);

            TokenParser.Result result = parser.Next(TokenParser.TokenType.TimeSpan);

            Assert.IsNotType(typeof (TokenParser.ResultEmpty), result);
            Assert.IsNotType(typeof(TokenParser.ResultError), result);

            Assert.IsType(typeof(TimeSpan), result.Value);

            Assert.Equal<TimeSpan>((TimeSpan)result.Value, new TimeSpan(days, hours, minutes, seconds));
        }
    }
}